-- Group B Transmit Team
-- February 24, 2007
-- This file represents the basis of a frame pointer component.
-- It will store a pointer to a frame and will be the base component for the frame pointer buffer

Library ieee;
Use ieee.std_logic_1164.all;

Entity FramePointer Is
	Port( MoveInAddr		: In Std_logic_vector(8 downto 0);
		  MoveInCRC			: In Std_logic;
		  MoveInTag			: In Std_logic_vector(31 downto 0);
			Clock			: In Std_logic;
			Move			: In Std_logic;
			Set				: In Std_logic;
			WriteInAddr		: In Std_logic_vector(8 downto 0);
			WriteInCRC		: In Std_logic;
			WriteInTag		: In Std_logic_vector(31 downto 0);
			OutputAddr		: Out Std_logic_vector(8 downto 0);
			OutputCRC		: Out Std_logic;
			OutputTag		: Out Std_logic_vector(31 downto 0);
			Address			: Buffer Std_logic_vector(8 downto 0);
			CRC				: Buffer Std_logic;
			Tag				: Buffer Std_logic_vector(31 downto 0));
End FramePointer;

Architecture Behavior Of FramePointer Is
Constant Zeros : Std_logic_vector(8 downto 0) := "000000000";

Begin
	Process
	Begin
		Wait Until Clock'Event And Clock = '1';
		
		If Move = '1' Then
			If Set = '0' Then
				Address <= MoveInAddr;
				CRC <= MoveInCRC;
				Tag <= MoveInTag;
			Else
				Address <= WriteInAddr;
				CRC <= WriteInCRC;
				Tag <= WriteInTag;
			End If;
		Else
			If Set = '1' Then
				Address <= WriteInAddr;
				CRC <= WriteInCRC;
				Tag <= WriteInTag;
			End If;
		End If;
		
		OutputAddr <= Address;
		OutputCRC <= CRC;
		OutputTag <= Tag;
	End Process;
End Behavior;